<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .outer {
            width: 400px;
            height: 400px;
            background-color: gray;
            display: flex;
            position: relative;
            /* 方案一 */
            /* justify-content: center;
            align-items: center; */

            /* 方案二 */
        }

        .inner {
            width: 100px;
            height: 100px;
            background-color: orange;
            /* margin: auto; */
            position: absolute;
            left: 50%;
            top: 50%;
            /* margin-left: -50px;
            margin-top: -50px; */
            transform: translate(-50%, -50%);
        }
    </style>
</head>
<body>

    <div class="outer">
        <div class="inner"></div>
    </div>
    
</body>
</html>